package com.demo.zyt.modules.app.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.demo.zyt.modules.app.utils.WeChatUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class AccessTokenRefreshTask {
	
	@Autowired
	private AccessTokenStore accessTokenStore;

	@Scheduled(cron = "0 0 0/1 * * ? ")
	// @Scheduled(cron = "0/5 * * * * ?")
    public void scheduled(){
		
		log.info("accessTokenStore is {}", this.accessTokenStore.getAccessToken());
		
        log.info("=====>>>>>使用cron  {}",System.currentTimeMillis());
        
        this.accessTokenStore.setAccessToken(WeChatUtils.getAccessToken());
    }
}
